package ua.com.mind_tree.client;

import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author suamo ( 01.05.12 1:26 )
 */
public class PageManager {
    private static PageManager instance = new PageManager();
    private static LayoutPanel layoutPanel = new LayoutPanel();

    private PageManager() {
    }

    public static PageManager getInstance() {
        return instance;
    }

    public void setMenu(Widget menu){
//        ShowMorePagerPanel pagerPanel = new
        menu.addStyleName("menu");
        layoutPanel.add(menu);
        layoutPanel.setWidgetLeftWidth(menu, 0, Style.Unit.PCT, 20, Style.Unit.PCT);
        RootLayoutPanel.get().add(layoutPanel);

    }

    public void setContent(Widget content){
        RootLayoutPanel rootLayoutPanel = RootLayoutPanel.get();
        rootLayoutPanel.clear();

        content.addStyleName("content");
        if (layoutPanel.getWidgetCount() > 1){
            layoutPanel.remove(1);
            layoutPanel.add(content);
        } else {
            layoutPanel.add(content);
        }
        layoutPanel.setWidgetRightWidth(content, 0, Style.Unit.PCT, 80, Style.Unit.PCT);
        rootLayoutPanel.add(layoutPanel);

    }

}
